// @flow

export const USER_MENU = 'USER_MENU'

type Action = {
  type: string,
  userMenu: Object
}

export const saveUserMenu = (userMenu: Object) => {
  return {
    type: USER_MENU,
    userMenu
  }
}

const ACTION_HANDLERS = {
  [USER_MENU]: (state, { userMenu }: Action) => Object.assign({}, state, {
    userMenu: userMenu
  })
}

type State = Object

const initialState = {
  userMenu: {}
}

export default function userMenuReducer (state: State = initialState, action: Action) {
  const handler = ACTION_HANDLERS[action.type]

  return handler ? handler(state, action) : state
}
